import { cva, type VariantProps } from 'class-variance-authority'
import { cn } from '../../lib/utils'

// 导出表格组件
export { default as Table } from './main.vue'

// 表格变体配置
export const TableVariants = cva('cg-table', {
  variants: {
    variant: {
      default: 'bg-white',
      striped: 'bg-white',
      bordered: 'bg-white border border-gray-200'
    },
    size: {
      small: 'text-sm',
      medium: 'text-base',
      large: 'text-lg'
    }
  },
  defaultVariants: {
    variant: 'default',
    size: 'medium'
  }
})

// 表格变体类型
export type TableVariants = VariantProps<typeof TableVariants>

// 表格基础样式类
export const TableClass = cn(
  'table-fixed',
  'border-collapse',
  'w-full',
  'min-h-24',
  'bg-white',
  'rounded-md',
  'overflow-hidden'
)

// 表头容器样式类
export const TableHeaderClass = cn(
  'w-full',
  'overflow-hidden',
  'box-border',
  'border-solid',
  'border-t-1',
  'border-l-1',
  'border-r-1',
  'border-b-0',
  'border-gray-100',
  'bg-gray-50'
)

// 表体容器样式类
export const TableBodyClass = cn(
  'w-full',
  'overflow-hidden',
  'box-content',
  'border-solid',
  'border-l-1',
  'border-r-1',
  'border-b-1',
  'border-gray-100',
  'bg-white'
)

// 分页容器样式类
export const TablePaginationClass = cn(
  'text-right',
  'p-4',
  'box-border',
  'border-t-1',
  'border-gray-100',
  'bg-gray-50'
)

// 单元格基础样式类
export const TableCellClass = cn(
  'min-w-0',
  'box-border',
  'overflow-hidden',
  'text-ellipsis',
  'text-left',
  'relative',
  'vertical-align-middle',
  'py-3',
  'px-4',
  'border-b-1',
  'border-gray-100'
)

// 表头单元格样式类
export const TableHeaderCellClass = cn(
  TableCellClass,
  'font-semibold',
  'text-gray-600',
  'bg-gray-50',
  'border-r-1',
  'border-gray-100'
)

// 表体单元格样式类
export const TableBodyCellClass = cn(
  TableCellClass,
  'text-gray-800',
  'border-r-1',
  'border-gray-100',
  'hover:bg-gray-50',
  'transition-colors'
)

// 操作列样式类
export const TableOperationCellClass = cn(
  TableBodyCellClass,
  'py-2',
  'flex',
  'justify-center',
  'gap-2'
)

// 空数据提示样式类
export const TableEmptyClass = cn(
  'min-h-[160px]',
  'h-full',
  'w-full',
  'flex',
  'items-center',
  'justify-center',
  'text-gray-500',
  'text-sm',
  'border-r-1',
  'border-b-1',
  'border-gray-100'
)
